const tags = {
    name: "theaters",
    description: "放映厅管理模块",
};

const schemas = {
    // 获取当前页面的条件的数据结构
    ArrayOftheaters: {
        properties: {
            total: {
                type: "number",
                description: "总数",
            },
            maxPage: {
                type: "number",
                description: "总页数",

            },
            rows: {
                type: "array",
                description: "放映厅当页数据",
                items: {
                    $ref: "#/components/schemas/theaters"
                }
            }
        }
    },
    // 每条放映厅数据的结构
    theaters: {
        properties: {
            _id: {
                type: "string",
                description: "唯一标识",
            },
            cname: {
                description: "放映厅名称",
                type: "string",
            },
            ename: {
                description: "放映厅是否营业",
                type: "boolean",
            },
            type: {
                description: "放映厅所属影院",
                type: "string",
            },
        }
    },
    // 新增放映厅结构
    addtheaters: {
        properties: {
            _id: {
                type: "string",
                description: "唯一标识",
            },
            name: {
                description: "放映厅名称",
                type: "string",
            },
            ename: {
                description: "放映厅营业状态",
                type: "boolean",
            },
            images: {
                description: "放映厅所属影院",
                type: "string",
               }
        }
    },
    // 新增放映厅返回值结构
    addReturn: {
        properties: {
            status: {
                type: "boolean",
                description: "是否成功状态,true为成功，false为失败",
            },
        },
    },
    // 删除放映厅结构
    removetheaters: {
        properties: {
            _id: {
                type: "string",
                description: "id值",
            }
        }
    },
    // 删除放映厅返回值结构
    removeReturn: {
        properties: {
            status: {
                type: "boolean",
                description: "是否成功状态,true为成功，false为失败",
            },
        },
    },
    // 修改放映厅结构
    changetheaters: {
        properties: {
            _id: {
                type: "string",
                description: "唯一标识",
            },
            name: {
                description: "放映厅名称",
                type: "string",
            },
            ename: {
                description: "放映厅营业状态",
                type: "boolean",
            },
            images: {
                description: "放映厅所属影院",
                type: "string",
               }
        }
    },
    // 删除放映厅返回值结构
    changeReturn: {
        properties: {
            status: {
                type: "boolean",
                description: "是否成功状态,true为成功，false为失败",
            },
        },

    }

};

const paths = {
    "/theaters": {
        get: {
            tags: ["theaters"],
            summary: "获取放映厅当页数据信息,渲染到放映厅列表",
            description: "获取当页的放映厅数据", // 具体描述
            consumes: ["application/json"],
            // parameters 请求参数
            parameters: [
                {
                    name: "curPage",
                    in: "query",    //get类型的参数在query中获取
                    schema: {
                        type: "integer",   //integer 整数
                        default: 1,
                    },
                    required: true,  //必填
                    description: "当前⻚码",
                },
                {
                    name: "eachPage",
                    in: "query",
                    schema: {
                        type: "integer",
                        default: 1,
                    },
                    required: true,
                    description: "每⻚显示条数",
                },
            ],
            responses: {
                200: {
                    description: "操作成功",
                    content: {
                        "application/json": {
                            schema: {
                                $ref: "#/components/schemas/ArrayOftheaters",
                            },
                        },
                    },
                },
                404: {
                    description: "找不到资源",
                },
            },
        },
    },
    "/theaters/add": {
        post: {
            tags: ["theaters"], //属于哪一个功能模块
            summary: "新增放映厅",
            // 具体描述
            description: "这是一个新增放映厅功能，需传入放映厅相对应的参数",
            consumes: ["application/json"], //请求的数据类型 JSON
            requestBody: {    //请求参数
                required: true, //必填
                content: {  //内容(具体参数)
                    "application/json": {
                        schema: {//参数的结构
                            $ref: "#/components/schemas/addtheaters",
                        },
                        // example 例子
                        example: {
                            "_id": "614ee6aedc364c19d8bee169",
                            "name": "1号放映厅",
                            "status": false,
                            "cinemas": "万达影城",
                          },
                    },
                },
            },
            // 响应
            responses: {
                // http状态码
                200: {
                    description: "操作成功",
                    content: {
                        "application/json": {
                            schema: {
                                $ref: "#/components/schemas/addReturn",
                            },
                        },
                    },
                },
                404: {
                    description: "找不到资源",
                },
            },
        },
    },
    "/theaters/remove": {
        delete: {
            tags: ["theaters"], //属于哪一个功能模块
            summary: "删除放映厅",
            // 具体描述
            description: "这是一个删除放映厅功能，需传入放映厅相对应的参数",
            consumes: ["application/json"], //请求的数据类型 JSON
            requestBody: {    //请求参数
                required: true, //必填
                content: {  //内容(具体参数)
                    "application/json": {
                        schema: {//参数的结构
                            $ref: "#/components/schemas/removetheaters",
                        },
                        // example 例子
                        example: {
                            _id: "614d673f0037f4201c411b1f",
                        },
                    },
                },
            },
            // 响应
            responses: {
                // http状态码
                200: {
                    description: "操作成功",
                    content: {
                        "application/json": {
                            schema: {
                                $ref: "#/components/schemas/removeReturn",
                            },
                        },
                    },
                },
                404: {
                    description: "找不到资源",
                },
            },
        },
    },
    "/theaters/change": {
        put: {
            tags: ["theaters"], //属于哪一个功能模块
            summary: "修改放映厅",
            // 具体描述
            description: "这是一个修改放映厅功能，需传入放映厅相对应的参数",
            consumes: ["application/json"], //请求的数据类型 JSON
            requestBody: {    //请求参数
                required: true, //必填
                content: {  //内容(具体参数)
                    "application/json": {
                        schema: {//参数的结构
                            $ref: "#/components/schemas/changetheaters",
                        },
                        // example 例子
                        example: {
                            "_id": "614ee6aedc364c19d8bee169",
                            "name": "1号放映厅",
                            "status": false,
                            "cinemas": "万达影城",
                          },
                    },
                },
            },
            // 响应
            responses: {
                // http状态码
                200: {
                    description: "操作成功",
                    content: {
                        "application/json": {
                            schema: {
                                $ref: "#/components/schemas/changeReturn",
                            },
                        },
                    },
                },
                404: {
                    description: "找不到资源",
                },
            },
        },
    }

}

module.exports = { tags, schemas, paths };